<?php
/**
 * 
 * 회원 정보 model
 * @author gudals
 * @since 2012-11-19
 *
 */

class modelContUserInfo extends modelContBase
{
    /**
     * 
     * 회원등록
     * @param array $aReq 등록정보
     * @return boolean
     */
    public function insert($aReq)
    {
        if (empty($aReq)) return false;

        $sQuery = "
            insert into user_info set
                user_email = '".$aReq['user_email']."',
                user_pass = '".$aReq['user_pass']."',
                user_nick = '".$aReq['user_nick']."',
                user_gender = '".$aReq['user_gender']."',
                user_birth = '".$aReq['user_birth']."',
                user_ip = '".$_SERVER['REMOTE_ADDR']."',
                user_photo = '".$aReq['upload_img']."',
                user_regist_dt = now()
        ";
        
        $this->executeQuery($sQuery, 'exec');
        return $this->lastInsertID();
    }
    
    /**
     * 
     * 로그인 정보 조회
     * @param array $aReq 로그인 정보
     * @return boolean|Ambigous <NULL, multitype:void , void, unknown>
     */
    public function geLoginInfo($aReq)
    {
        if (empty($aReq)) return false;
        
        $sQuery = "
            select
                user_no,
                user_email,
                user_nick,
                user_gender,
                user_birth,
                user_photo,
                user_level
            from
                user_info
            where
                user_email = '".$aReq['login_id']."'
            and
                user_pass = '".$aReq['login_pass']."'
        ";
        
        return $this->executeQuery($sQuery, 'row');
    }
    
    /**
     * 
     * 회원 상세 정보
     * @param int $iUserNo 회원코드
     */
    public function getInfo($iUserNo)
    {
        if (empty($iUserNo)) return fasle;
        
        $sQuery = "
            select
                *
            from
                user_info
            where
                user_no = '".$iUserNo."'
        ";
        
        return $this->executeQuery($sQuery, 'row');
    }
    
    /**
     * 
     * 이메일 정보가 있는지 확인
     * @param string $sUserEmail 이메일
     * @return boolean|Ambigous <NULL, multitype:void , void, unknown>
     */
    public function getEmailInfo($sUserEmail)
    {
        if (empty($sUserEmail)) return false;
        
        $sQuery = "
            select
                user_no
            from
                user_info
            where
                user_email = '".$sUserEmail."'
        ";
        
        return $this->executeQuery($sQuery, 'row');
    }
}